const KoaRouter =require('@koa/router')
const router =new KoaRouter()
const checkToken = require('../middlewares/checkToken')

const U=require('../controllers/webapp/user')
const G=require('../controllers/webapp/good')
const List=require('../controllers/webapp/list')
const C=require('../controllers/webapp/cart')
// 动态资源服务：把所有的
// router.get('/gp6',(ctx)=>{
//      ctx.body='hello'; 
//     })
const v='/api/v1'
router
.get(`${v}/getUserList`,U.getUserList)
.get(`${v}/getGoodList`,G.getGoodList)
.get(`${v}/list`,List.getList)
.get(`${v}/getAllCates`,G.getAllCates)
.get(`${v}/getGoodDetail`,G.getGoodDetail)
.get(`${v}/user/getUser`,U.getUser)
.post(`${v}/user/register`,U.register)
.post(`${v}/cart/add`, checkToken, C.addToCart)
.get(`${v}/cart/list`, checkToken, C.getCartList)
.get(`${v}/cart/del`, checkToken, C.delCartItem)
.get(`${v}/cart/upd`, checkToken, C.updCartCount)
.post(`${v}/cart/submit`, checkToken, C.submitCart)
module.exports=router